#include "logmodel.h"
LogModel *LogModel::instance = nullptr;

LogModel *LogModel::getInstance()
{
    if(LogModel::instance == nullptr)
    {
        LogModel::instance = new LogModel;
    }
    return LogModel::instance;
}

int LogModel::InsertLog(QString date, QString configure, QString name, QString log_opera)
{
    QString sql = QString ("insert into tbl_log(log_date, log_configure, user_name, log_opera) values('%1', '%2', '%3', '%4')").arg(date).arg(configure).arg(name).arg(log_opera);
    int res = SingletonBD::getInstance()->doUpdateInsertDel(sql);
    return res;
}

int LogModel::selectLog(char **&qres, int &row, int &col)
{
    QString sql = QString("SELECT log_date, log_configure, user_name, log_opera FROM tbl_log ORDER BY log_id DESC  LIMIT 10;");
    int res = SingletonBD::getInstance()->doSelect(sql, qres, row, col);
    if(res==0)
    {
        if(row>0)       //有数据   登陆成功    更新用户状态
        {
            return 0;
        }
    }
    return -1;  //返回默认值
}

LogModel::LogModel()
{

}
